<%@page import="com.is.control.ParamClassControl"%>
<%@page import="com.is.export.control.SelectOptionValue"%>
<%@page import="java.util.LinkedHashMap"%>
<%@page import="com.is.control.ParamCourseControl"%>
<%@page import="com.is.control.CourseClassControl"%>
<%@page import="com.is.model.CourseClass"%>
<%@page import="com.is.export.model.OnceTimeExport"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.is.control.StudentControl"%>
<%@page import="com.is.control.AttendanceDetailControl"%>
<%@page import="com.is.control.HomeworkTimeControl "%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="com.is.model.User"%>
<%@page import="com.is.util.ParamUtil"%>
<%@page import="java.util.List"%>
<%@page import="com.is.model.HomeworkTime"%>
<%@page import="com.is.model.AttendanceDetail"%>
<%@page import="com.is.control.ParamReasonTypeControl"%>
<%@page import="com.is.model.Student"%>
<%@page import="com.is.model.AttendanceTime"%>
<%@page import="com.is.control.AttendanceTimeControl"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.Map"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="/InterStu/resources/image/favicon.ico" />
<link rel="stylesheet" type="text/css" href="../../resources/css/all.css" />
<link rel="stylesheet" type="text/css" href="../../resources/css/add.css" />
<script type="text/javascript" src="../../resources/js/jquery-1.8.1.js"></script>
<script type="text/javascript" src="../../resources/js/WebCalendar.js"></script>
<link href="../../resources/css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../resources/js/jquery.artDialog.js"></script>
<script type="text/javascript" src="../../resources/js/iframeTools.js"></script>
<script type="text/javascript">
	$(function(){
		var block = $("#magic_block");
		if($(".active a").position()){
			block.css("top",$(".active a").position().top+10)
			.data("oriTop",$(".active a").position().top)
		}
		$(".nav ul li").find("a").hover(
			function(){
				var $this = $(this);
				var newTop = $this.position().top;
				block.stop().animate({
					top:newTop+10
				})
			},
			function(){
				block.stop().animate({
					top:block.data("oriTop")+10
				})
			}
		)
		var h = $(".right").height();
		$(".left").height(h);
		$(".update").click(function(){
			$.dialog.open("/InterStu/update_info.jsp",{width:460,height:400,title:"个人信息"});
		})
		$('img').error(function(){
			this.src = "/InterStu/resources/image/man.GIF";
		})
		/*updateAttendance*/
		$("[name='updateAttendance']").change(function(e){
			e.preventDefault();
			var $this = $(this);
			var stu_id = $this.parent().find("[name='stuId']").val();
			var time_id = $this.parent().find("[name='timeId']").val();
			var changeTo = $this.val();
			$.dialog.confirm('你确定要修改该学生的出勤情况吗？', function () {
			    $.ajax({
						type:"post",
						url:"updateAttendance.jsp",
						data:{
							value:changeTo,
							stuId:stu_id,
							timeId:time_id
						},
						success:function(data){
							if (data == 1){
								$this.css("border","1px solid red")
							}
						}
					})
					$.dialog.tips('修改操作已执行');
			}, function () {
				$this.css("border","1px solid green")
			    $.dialog.tips('修改操作已取消');
			});
		})
	})
</script>
<title>留学生预科班</title>
</head>
<body>
<%
		User cu = (User)session.getAttribute("user");
%>
<div class="header">
	<div class="title pr">
    	<a href="javascript:void(0);"><span class="update pa">个人信息</span></a>
        <span class="logout pa"><a class="hide" href="/InterStu/login/logout.jsp">退出</a></span>
    </div>
</div>
<div class="main">
	<div class="left">   
		<div class="infomation">
			<div class="photo">
			<%
			String picUrl = cu.getPicUrl();
			if(session.getAttribute("picUrl")!=null){
			    picUrl = "/InterStu/User/UserHeadImage/"+(String)session.getAttribute("picUrl");
			}	
			//System.out.print(picUrl);
			%>
				<img width='60' height="60" src = "<%=picUrl %>"  />
			</div>
			<div class="welcome">
				<%=cu.getName() %>,<br/>
				欢迎您使用！
			</div>
		</div>   	
    	<div class="nav">
        	<ul>	
        		<li class="pa" id="magic_block"></li>
            	<%if(cu!=null&&cu.getRole().equals("1")){ %>
                <li><a href="/InterStu/pages/stuyear/stuyear_start.jsp">新学期设置</a></li>
                <li><a href="/InterStu/pages/users/user_all.jsp">用户管理</a></li>
                <%} %>
                <li class="active"><a href="/InterStu/pages/students/student_add.jsp">学生管理</a></li>
                <li><a href="/InterStu/pages/dictation/dictation_add.jsp">学生考核</a></li>
                <%if(cu!=null&&cu.getRole().equals("1")){ %>
                <li><a href="/InterStu/pages/assess/teacher_assess.jsp">教职人员管理</a></li>
                <%} %>
            </ul>
        </div>
    </div>
    <div class="right">
    	<div class="r1">
    	<table class="student tab">
    <tr>
    <%if(cu!=null&&cu.getRole().equals("1")){ %>
    	<td>
    		<a href="/InterStu/pages/students/student_add.jsp">添加学生</a>
		</td>
		<%} %>
		<td>
			<a href="/InterStu/pages/students/student_admin.jsp">查看学生</a>
		</td>
		<td>
			<a class='current' href="/InterStu/pages/attendance/attendance_add.jsp">学生出勤</a>
		</td>
    </tr>
    </table>
	    </div>
	    <div class="r2">
<%
               int dtId = ParamUtil.getInt(request,"dt",7);
               if(dtId==0){
            	   out.print("没有找到相关数据");
               }else{
        	       AttendanceTime dt = AttendanceTimeControl.getAttendanceTimebyId(dtId);
        	       //CourseClass cc = CourseClassControl.getCourseClassById(dt.getCourseClassId());
        	       
            	   ArrayList<AttendanceDetail> dictations = AttendanceDetailControl.getAttendanceDetailByTimeId(dtId);
            	   List<OnceTimeExport> exportList = new ArrayList<OnceTimeExport>();
            	   CourseClass cc = CourseClassControl.getCourseClassById(dt.getCourseClassId());
            	   List<Student> stus = StudentControl.getStudentByClassId(cc.getClassId()+"");
            	   %>
            	   <form>
            	   <table class="table">
            	   <caption class="pr"> 
            	   		<%=dt.getTime() %>【<%=ParamClassControl.getClassName(cc.getClassId())+ParamCourseControl.getCourseById(cc.getCourseId()).getCourseName() %>】学生出勤情况详细信息 <a href="/InterStu/servlet/ExportDo"  target="_blank">【导出结果】</a>
            	   		<span class="print pa"><a href="javascript:window.history.go(-1)">返回</a></span>
            	   </caption>
            	   <thead>
            	   <tr>
            	   <th>学生</th><th>出勤情况</th><th>学生</th><th>出勤情况</th></tr>
            	   </thead>
            	   <tbody>
            	   <tr>
            	   <%
            	   //System.out.println("DDDDD"+dtId+"TTT");
            	   for(int i=0;i<stus.size();i++){
            	       Student stu = stus.get(i);
            	       //System.out.println(stu.getId() + "|" +dtId);
            		   int type = AttendanceDetailControl.getReasonTypeByStuIdAndTimeId(stu.getId(),dtId);
            		   //System.out.println(stu.getId()+"TTT"+type+"TTT");
            		   String result = "正常出勤";
            		   if(type!=0){
            		       result=ParamReasonTypeControl.getTypeNameById(type);
            		   }
            		   OnceTimeExport  ote = new OnceTimeExport(); 
            		   ote.setStuName(stu.getChineseName());
            		   ote.setResult(result);
            		   exportList.add(ote);
            		   %>
            		   <td><%=stu.getChineseName() %></td>
            		   
            		   <td>
            		   		<input type="hidden" value="<%=stu.getId() %>" name="stuId"/>
            		   		<input type="hidden" value="<%=dtId %>" name="timeId"/> 
            		   	<select name="updateAttendance">
            		   <% 
            		   	HashMap map = ParamReasonTypeControl.getRessonMap();
            		   	Iterator it = map.entrySet().iterator();
            		   	while(it.hasNext()){
            		   		Map.Entry entry = (Map.Entry)it.next();
            		   %>
            		   	  <option value="<%=entry.getKey()%>" <%=type == Integer.parseInt(entry.getKey().toString())?"selected":"" %>><%=entry.getValue() %></option> 
            		   	  <%if(type == Integer.parseInt(entry.getKey().toString())){ out.print(entry.getValue());} %>
            		   	  <%if(type==0) out.print("正常出勤");else{out.print(ParamReasonTypeControl.getTypeNameById(type));}%>
            		   <%	
            		   	}
            		   %>
            		   		 </select>
            		   </td>
            		   <%if(i%2==1) out.print("</tr><tr>") ;%>
            		   <%
            	   }
            	     session.removeAttribute("exportList");
            	 	 session.setAttribute("exportList",exportList);
            	 	 session.removeAttribute("fileName");
            	 	// session.setAttribute("fileName",ParamCourseControl.getCourseById(cc.getCourseId()).getCourseName()+dt.getTime()+"作业情况");
            	 	session.setAttribute("fileName",ParamCourseControl.getCourseById(cc.getCourseId()).getCourseName()+dt.getTime()+"出勤情况");
            	 	 LinkedHashMap<String,String> exportOps = SelectOptionValue.OnceTime();
            	 	 session.removeAttribute("exportOps");
                	 session.setAttribute("exportOps",exportOps);
                	 session.removeAttribute("className");
                	 session.setAttribute("className","com.is.export.model.OnceTimeExport");
            	   %>
            	   </tr>
            	   </tbody>
            	   </table>
            	   </form>
            	   <%
            	            	   
               }
%>
		</div>
</div>
</div>
<div class="footer">
	<p>版权所有：东北师范大学留学生预科部&nbsp;&nbsp;  蓝旭工作室开发</p>
</div>
</body>
</html>